#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

int main()
{
    FILE* pf = fopen("log.txt", "w");
    if(pf == NULL)
    {
        printf("%s\n", strerror(errno));
        return 1;
    }
    const char* msg = "hello bit: ";
    int count = 1;
    //while(count <= 10)
    while(1)
    {
        sleep(2);
        char buffer[1024];
        snprintf(buffer, sizeof(buffer), "%s%d\n", msg, count++);

        size_t n = fwrite(buffer, strlen(buffer), 1, pf);
        if(n != 1)
        {
            perror("fwrite");
            return 1;
        }
    }


    fclose(pf);

    return 0;
}
